package core;


import java.util.HashMap;

public class ParamsContext<K,V> {
    private final HashMap<K,V> params = new HashMap<>();

    public V getVal(K key){
        if(key == null){
            throw new NullPointerException("key is null");
        }
        return params.get(key);
    }

    public V putVal(K key,V val){
        if(key == null || val == null){
            throw new NullPointerException("key or val is null");
        }
        if(!params.containsKey(key)){
           return params.put(key, val);
        }else{
            params.remove(key);
            params.put(key, val);
        }
        return null;
    }
}
